class Topic {
  int? id;
  String title;
  String coverImage;
  String content;
  String label;
  int numberPeople;
  int userId;

  Topic({
    this.id,
    required this.title,
    required this.coverImage,
    required this.content,
    required this.label,
    required this.numberPeople,
    required this.userId,
  });

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'title': title,
      'coverImage': coverImage,
      'content': content,
      'label': label,
      'numberPeople': numberPeople,
      'userId': userId,
    };
  }

  factory Topic.fromMap(Map<String, dynamic> map) {
    return Topic(
      id: map['id'],
      title: map['title'],
      coverImage: map['coverImage'],
      content: map['content'],
      label: map['label'],
      numberPeople: map['numberPeople'],
      userId: map['userId'],
    );
  }

  Topic copyWith({
    int? id,
    String? title,
    String? coverImage,
    String? content,
    String? label,
    int? numberPeople,
    int? userId,
  }) {
    return Topic(
      id: id ?? this.id,
      title: title ?? this.title,
      coverImage: coverImage ?? this.coverImage,
      content: content ?? this.content,
      label: label ?? this.label,
      numberPeople: numberPeople ?? this.numberPeople,
      userId: userId ?? this.userId,
    );
  }
}
